package com.jzy.util;

import java.security.MessageDigest;
import java.util.UUID;

/**
 * @Auther 姬海威 [haiwei.ji@tigermed.net]
 * @Date 2017-11-20 14:34
 */
public class Md5Utils {

    public static String MD5(String data) throws Exception {
        MessageDigest md = MessageDigest.getInstance("MD5");
        byte[] array = md.digest(data.getBytes("UTF-8"));
        StringBuilder sb = new StringBuilder();
        for (byte item : array) {
            sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
        }
        return sb.toString().toUpperCase();
    }

    public static String generateUuid() {
        return UUID.randomUUID().toString().replaceAll("-", "").substring(0, 32);
    }

    public static void main(String[] args) {
        System.out.println(String.valueOf(System.currentTimeMillis()).length());
    }
}
